home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 187_01 / detabs.c < prev    next >
Text File  |  1985-12-28  |  1KB  |  37 lines

  1. /*@*****************************************************/
  2. /*@                                                    */
  3. /*@ detabs - remove tabs from input string.            */
  4. /*@        Assumes a fixed tab interval.               */
  5. /*@                                                    */
  6. /*@   Usage:   detabs(out, in, interval, omax);        */
  7. /*@       where out is the output string area.         */
  8. /*@             in  is the input string area.          */
  9. /*@             interval is the fixed tab interval.    */
  10. /*@             omax is the max output area size.      */
  11. /*@                                                    */
  12. /*@*****************************************************/
  13.  
  14.  
  15. detabs(bufo,bufi,tabsize,omax)    /* remove tabs from input string */
  16. char bufi[], bufo[];
  17. int tabsize, omax;
  18. {
  19.     char c;
  20.     int ii, io;
  21.  
  22.     ii = io = 0;
  23.     while ((c = bufi[ii++]) && io < omax)        /* till end of string */
  24.         if (c == '\t') {
  25.             bufo[io++] = ' ';
  26.             while ((io % tabsize) && io < omax)    /* space to next tab */
  27.                 bufo[io++] = ' ';
  28.         }
  29.         else
  30.             bufo[io++] = c;
  31.  
  32.     bufo[io] = '\0';
  33.  
  34.  
  35. }
  36.  
  37.